package com.itheima.note.controller.v1;

import com.itheima.model.common.dtos.ResponseResult;
import com.itheima.model.note.dtos.NoteDto;
import com.itheima.note.service.impl.NoteServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1")
@Api(value = "笔记相关的接口",tags = "笔记相关的接口")
public class NoteController {
    @Autowired
    private NoteServiceImpl noteService;

    /**
     * 获取笔记列表
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("获取笔记列表")
    public ResponseResult getNoteList(@RequestBody NoteDto dto){
        return noteService.getNoteList(dto);
    }

    /**
     * 新增笔记
     * @param dto
     * @return
     */
    @PostMapping()
    @ApiOperation("新增笔记")
    public ResponseResult addNote(@RequestBody NoteDto dto){
        return noteService.addNote(dto);
    }
    /**
     * 修改笔记
     * @param dto
     * @return
     */
    @PutMapping()
    @ApiOperation("修改笔记")
    public ResponseResult updateNote(@RequestBody NoteDto dto){
        return noteService.updateNote(dto);
    }
    /**
     * 删除笔记
     */
    @DeleteMapping("/{id}")
    @ApiOperation("删除笔记")
    public ResponseResult deleteNote(@PathVariable String id){
        return noteService.deleteNote(id);
    }
    
    /**
     * 根据ID获取笔记详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("根据ID获取笔记详情")
    public ResponseResult getNoteById(@PathVariable String id){
        return noteService.getNoteById(id);
    }
}
